package com.project.seckill.controller.publicapi;

import com.project.seckill.bo.JsonEntity;
import com.project.seckill.constant.CodeMessage;
import com.project.seckill.util.ResponseHelper;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by yachao on 2018/6/24.
 */
@Controller
@RequestMapping("/demo")
public class DemoPublicApi {

    @RequestMapping("/")
    String index(Model model) {
        model.addAttribute("name", "jangz");
        return "index";
    }

    @RequestMapping("/hello")
    @ResponseBody
    public JsonEntity<String> hello() {
        return ResponseHelper.of("Hello Jang!");
    }
    @RequestMapping("/helloError")
    @ResponseBody
    public JsonEntity<String> helloError() {
        return ResponseHelper.error(CodeMessage.SERVER_ERROR);
    }
}
